#include "stdafx.h"
#include "General.h"
#include "Scene.h"
#include "config.h"
#include "Kingdom.h"

sgObject * sgGeneral::Creator()
{
    return new sgGeneral;
}

bool sgGeneral::m_creatorRegisted = CObjectManager::Instance().RegisteCreator(OBJ_GENERAL, sgGeneral::Creator );


sgGeneral::sgGeneral( int type /*= 0 */ )
{
    m_type = type;
    m_owner = NULL;
    m_classType = OBJ_GENERAL;
}

sgGeneral::~sgGeneral()
{

}

GeneralEntry & sgGeneral::GetEntry()
{
    return m_entry;
}

bool sgGeneral::Initialize()
{
    bool ret = sgEntity::Initialize();
    m_layer = 0;
    const GeneralEntry *entry = Config::Instance().GetGeneralEntry( m_type );
    CHECK_PTR(entry, false);
    m_entry = *entry;
    m_entry.sizex = m_entry.sizey = 0;
    return ret;
}

sgGeneral * sgGeneral::Clone()
{
    return NULL;
}

void sgGeneral::Render()
{

}

void sgGeneral::Serialize( CSerialize& s )
{
    sgForceEntity::Serialize(s);
    s&MAKE_PAIR(m_entry.gender,"gender");
    s&MAKE_PAIR(m_entry.command,"command");
    s&MAKE_PAIR(m_entry.fight,"fight");
    s&MAKE_PAIR(m_entry.intellect,"intellect");
    s&MAKE_PAIR(m_entry.political,"political");
    s&MAKE_PAIR(m_entry.attraction,"attraction");
    s&MAKE_PAIR(m_entry.birth,"birth");
    s&MAKE_PAIR(m_entry.death,"death");
    s&MAKE_PAIR(m_entry.turnout,"turnout");
}
